package com.echo.fm.content.activity;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.echo.fm.content.activity.model.Action;
import com.echo.fm.content.activity.model.ActionItem;
import com.echo.util.ErrorException;

@Service("actionService")
public class DefaultActionServiceImpl implements IActionService {
	@Autowired
	@Qualifier("actionPersistence")
	IActionPersistence actionPersistence;

	public IActionPersistence getActionPersistence() {
		return actionPersistence;
	}

	public void setActionPersistence(IActionPersistence actionPersistence) {
		this.actionPersistence = actionPersistence;
	}

	public List<ActionItem> searchActionItemList(int actionId) throws ErrorException {

		return actionPersistence.searchActionItemList(actionId);
	}

	public int insertAction(Action action, List<ActionItem> itemList) throws ErrorException {

		return actionPersistence.insertAction(action, itemList);
	}

	public void updateAction(Action action, List<ActionItem> itemList) throws ErrorException {
		actionPersistence.updateAction(action, itemList);

	}

	public void updateAction(Action action) throws ErrorException {
		actionPersistence.updateAction(action);

	}

	public Action searchActionById(int id) throws ErrorException {
		return actionPersistence.searchActionById(id);
	}

	public void deleteAction(Action action) throws ErrorException {

		actionPersistence.deleteAction(action);

	}

	public List<Action> searchActionList(String title, Integer actionType, Integer status, Long searchStartTime,
			Long searchFinalTime, Integer loopStatus, Integer firstResults, Integer maxResults) throws ErrorException {
		return actionPersistence.searchActionList(title, actionType, status, searchStartTime, searchFinalTime,
				loopStatus, firstResults, maxResults);
	}

	public Long searchActionListCount(String title, Integer actionType, Integer status, Long searchStartTime,
			Long searchFinalTime, Integer loopStatus) throws ErrorException {
		return actionPersistence.searchActionListCount(title, actionType, status, searchStartTime, searchFinalTime,
				loopStatus);
	}

	public void test()  {
		actionPersistence.test();
	}

	public List<Action> searchActionList() throws ErrorException {
		return actionPersistence.searchActionList();
	}

}
